import Http from '@/utils/httpUtil'

export function getRoleAdd(data) { // 角色新增
  return Http.post('ucenter/role/addRole', data)
}
export function getRoleEdit(data) { // 角色修改
  return Http.post('ucenter/role/editRole', data)
}

export function getRoleDelete(data) { // 角色删除
  return Http.post('ucenter/role/delete', data)
}

export function getRoleList(data) { // 角色列表
  return Http.get('ucenter/role/getRoleByList', data)
}

export function getRoleInfo(data) { // 角色信息
  return Http.get('ucenter/sys/role/info/' + data)
}

export function getRoleRuleInfo(data) { // 获取用户角色权限
  return Http.get('ucenter/permission-entity/selectPermission', data)
}

export function getRoleUpdate(data) { // 修改角色权限
  return Http.post('ucenter/sys/roleOperation/update', data)
}
export function getRuleList() { // 操作权限
  return Http.get('ucenter/permission-entity/selectAllPermission')
}

// 获取权限树
export const getRoleTreeList = param => Http.get(`ucenter/permission-entity/tree`, param)

// 更新角色权限
export const updateRoleRule = param => Http.post(`ucenter/role-perm-entity/addAuthorize`, param)

/**
 * 通过角色id 获取角色权限
 */
export const getRoleRuleListById = param => Http.get(`ucenter/role-perm-entity/listPermByRoleId`, param)

/**
 * 角色授权
 */
export const addUsersRole = param => Http.post(`ucenter/users-role/addUsersRole`, param)

/**
 * 根据用户 id 和组织 id 获取该组织下的角色id
 */
export const getSelectRuleListById = param => Http.get(`ucenter/users-role/listRole`, param)
